package com.project.xsf.controller;

import com.project.common.entity.PageVo;
import com.project.xsf.entity.MProcedure;
import com.project.xsf.service.MProcedureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/mProcedure")
public class MProcedureController {
    @Autowired
    private MProcedureService mProcedureService;
    @PostMapping("/queryMProcedureByPId.action")
    @ResponseBody
    public PageVo<MProcedure> queryMProcedureByPIdAction(@RequestBody Map<String,String> map){
        PageVo<MProcedure> pageVo = mProcedureService.queryMProcedureByPId(map);
        return pageVo;
    }
    @PostMapping("/queryMProcedureByPId")
    @ResponseBody
    public PageVo<MProcedure> queryMProcedureByPId(@RequestBody Map<String,String> map){
        PageVo<MProcedure> pageVo = mProcedureService.queryMProcedureByPId(map);
        return pageVo;
    }
    @PostMapping("/transferProcedure.action")
    public int  transferProcedure(Integer mProcedureId,Double realAmount){
        MProcedure mProcedure = mProcedureService.selectByPrimaryKey(mProcedureId);
        mProcedure.setRealAmount(realAmount);
        //已交接
        mProcedure.setProcedureTransferTag("G005-1");
        return mProcedureService.updateByPrimaryKeySelective(mProcedure);

    }
    @PostMapping("/checkTransferMProcedure.action")
    public int checkTransferMProcedure(Integer mProcedureId){
        MProcedure mProcedure = mProcedureService.selectByPrimaryKey(mProcedureId);
        mProcedure.setProcedureTransferTag("G005-2");
        return mProcedureService.updateByPrimaryKeySelective(mProcedure);
    }
}
